/*
 * Program.cpp
 *
 *  Created on: Mar 31, 2012
 *      Author: user
 */

#include <MemoryManager.h>
#include <SpeculationManager.h>
#include <SpeculationTask.h>

class TestSpeculationTask : public SpeculationTask
{
private:
	char* _pMessage;

public:
	TestSpeculationTask(char* pMessage)
	: SpeculationTask("Default"),
	  _pMessage(pMessage)
	{
	}

	virtual void execute()
	{
		strcpy(_pMessage, "This is clone\n");
	}

	void Print()
	{
		printf(_pMessage);
	}
};

TestSpeculationTask * task;

SpeculationTask* createTask()
{
	return task;
}

int main (int argc, char ** argv)
{
	installMemoryWatcher();

	char* message = (char*) malloc(sizeof(char) * 1024);
	strcpy(message, "This is main program\n");

	removeMemoryWatcher();

	task = new TestSpeculationTask(message);

//	task->Print();

//	task->execute();

//	task->Print();

	SpeculationManager::Instance()->setSpeculationGenerator(createTask);

	SpeculationManager::Instance()->run();

	SpeculationManager::Instance()->startSpeculation("Default");

	SpeculationManager::Instance()->commitSpeculation(task);

	task->Print();

	return 0;
}


